﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RL
{
    public partial class FormVehicleLength : Form
    {
        private IEnumerable<VehicleLength> rpt_data;
        public FormVehicleLength()
        {
            InitializeComponent();
            rpt_data = null;
        }

        private void buttonExec_Click(object sender, EventArgs e)
        {
            crystalReportViewer1.Visible = true;
            DateTime begDate = dateTimePickerBegDate.Value;
            DateTime endDate = dateTimePickerEndDate.Value;
            DateTime reportEndDate = endDate;
            begDate = begDate.Date;
            endDate = endDate.Date.AddDays(1);
            ReportRouteList rt = new ReportRouteList();
            rpt_data = rt.makeLengthReport(begDate, endDate);
            crVehicleLength1.SetDataSource(rpt_data);
            crystalReportViewer1.ReportSource = crVehicleLength1;
            crVehicleLength1.SetParameterValue("BegDate", begDate.ToString("dd/MM/yyyy"));
            crVehicleLength1.SetParameterValue("EndDate", reportEndDate.ToString("dd/MM/yyyy"));
        }

        private void FormVehicleLength_Load(object sender, EventArgs e)
        {
            rpt_data = null;
            crystalReportViewer1.ReportSource = null;
        }
    }
}
